// https://umijs.org/config/
import { defineConfig } from 'umi';
import defaultSettings from './defaultSettings';
import proxy from './proxy';
const { REACT_APP_ENV } = process.env;
export default defineConfig({
  hash: true,
  antd: {},
  dva: {
    hmr: true,
  },
  history: {
    type: 'browser',
  },
  locale: {
    // default zh-CN
    default: 'zh-CN',
    antd: true,
    // default true, when it is true, will use `navigator.language` overwrite default
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@/components/PageLoading/index',
  },
  targets: {
    ie: 11,
  },
  // umi routes: https://umijs.org/docs/routing
  routes: [
    {
      path: '/',
      component: '../layouts/BlankLayout',
      routes: [
        {
          path: '/user',
          component: '../layouts/UserLayout',
          routes: [
            {
              path: '/user/login',
              name: 'login',
              component: './User/login',
            },
            {
              path: '/user',
              redirect: '/user/login',
            },
            {
              name: 'register-result',
              icon: 'smile',
              path: '/user/register-result',
              component: './user/register-result',
            },
            {
              name: 'register',
              icon: 'smile',
              path: '/user/register',
              component: './user/register',
            },
            {
              component: '404',
            },
          ],
        },
        {
          path:'/',
          component:'../layouts/SecurityLayout',
          routes:[
            {
              path: '/',
              component: '../layouts/BasicLayout',
              Routes: ['src/pages/Authorized'],
              authority: ['admin', 'user'],
              routes: [
                {
                  path: '/',
                  redirect: '/dashboard',
                },
                {
                  path: '/dashboard',
                  name: 'dashboard',
                  icon: 'dashboard',
                  routes: [
                    {
                      path: '/dashboard',
                      redirect: '/dashboard/workplace',
                    },
                    {
                      name: 'workplace',
                      icon: 'smile',
                      path: '/dashboard/workplace',
                      component: './dashboard/workplace',
                    },
                  ],
                },
                {
                  path: '/list',
                  icon: 'table',
                  name: 'list',
                  routes: [
                    {
                      path: '/',
                      redirect: '/list/article-list',
                    },
                    {
                      name: 'article-list',
                      icon: 'smile',
                      path: '/list/article-list',
                      component: './list/article-list',
                    },
                    {
                      name: 'article-edit',
                      icon: 'smile',
                      hideInMenu:true,
                      path: '/list/article-list/edit',
                      component: './list/article-list/edit',
                    },
                    {
                      name: 'category-list',
                      icon: 'smile',
                      path: '/list/category-list',
                      component: './list/category-list',
                    },
                    {
                      name: 'tag-list',
                      icon: 'smile',
                      path: '/list/tag-list',
                      component: './list/tag-list',
                    },
                    {
                      name: 'link-list',
                      icon: 'smile',
                      path: '/list/link-list',
                      component: './list/link-list',
                    },
                    {
                      name: 'comment-list',
                      icon: 'smile',
                      path: '/list/comment-list',
                      component: './list/comment-list',
                    }
                  ],
                },
                {
                  path: '/users',
                  icon: 'UsergroupDeleteOutlined',
                  name: 'users',
                  authority: ['admin'],
                  routes: [
                    {
                      path: '/',
                      redirect: '/users/user-list',
                    },
                    {
                      name: 'user-list',
                      icon: 'smile',
                      path: '/users/user-list',
                      component: './users/user-list',
                    }
                  ],
                },
                {
                  name: 'account',
                  icon: 'user',
                  path: '/account',
                  routes: [
                    {
                      path: '/',
                      redirect: '/account/center',
                    },
                    {
                      name: 'center',
                      icon: 'smile',
                      path: '/account/center',
                      component: './account/center',
                    },
                    {
                      name: 'settings',
                      icon: 'smile',
                      path: '/account/settings',
                      component: './account/settings',
                    },
                  ],
                },
                {
                  component: '404',
                },
              ],
            },
          ]
        },
        
      ],
    },
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    'primary-color': defaultSettings.primaryColor,
  },
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || 'dev'],
  publicPath:"/admin/",
  base:'/admin/'
});
